
import java.awt.Color;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

public class frm_main extends javax.swing.JFrame {

    public static String nivel_acesso;
    /** Creates new form frm_main */
    public frm_main(String nivel_acesso) {
        this.nivel_acesso = nivel_acesso;
        initComponents();
        verificarNivelAcesso();
      //  ImageIcon  imagemIcon = new ImageIcon("C://Clinica_De_Protese//Clinica_de_Protese//src//icons//benessere.jpg");
        //lbl_imagem.setIcon(imagemIcon);
        try {  
            javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");  
            javax.swing.SwingUtilities.updateComponentTreeUI(this); 
            Usuario user = new Usuario();
        } catch (Exception e) {  
        e.printStackTrace();  
        }
        setExtendedState(MAXIMIZED_BOTH);
        getContentPane().setBackground(new Color(255,255,255));
        verificarNivelAcesso();
    }
    
     public void verificarNivelAcesso(){
        if(nivel_acesso.equals("Operador")){
            jm_menu_usuarios.setEnabled(false);
            jm_menu_usuarios.setVisible(false);       
        }
        else{
            jm_menu_usuarios.setEnabled(true);
            jm_menu_usuarios.setVisible(true);
        }
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lbl_imagem = new javax.swing.JLabel();
        jm_menu = new javax.swing.JMenuBar();
        jm_menu_opcoes = new javax.swing.JMenu();
        jm_menu_backup = new javax.swing.JMenuItem();
        jm_menu_restaurar_backup = new javax.swing.JMenuItem();
        jm_menu_usuarios = new javax.swing.JMenuItem();
        jm_menu_sair = new javax.swing.JMenuItem();
        jm_menu_gerenciar = new javax.swing.JMenu();
        jm_menu_clinicas = new javax.swing.JMenuItem();
        jm_menu_dentistas = new javax.swing.JMenuItem();
        jm_menu_pacientes = new javax.swing.JMenuItem();
        jm_menu_ordem_de_servico = new javax.swing.JMenuItem();
        jm_menu_ajuda = new javax.swing.JMenu();
        jm_menu_conteudo_ajuda = new javax.swing.JMenuItem();
        jm_menu_sobre = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Clínica de Próteses | Principal");
        setBackground(java.awt.Color.white);

        lbl_imagem.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbl_imagem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/benessere.jpg"))); // NOI18N

        jm_menu_opcoes.setText("Opções");
        jm_menu_opcoes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jm_menu_opcoesActionPerformed(evt);
            }
        });

        jm_menu_backup.setText("Backup");
        jm_menu_backup.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jm_menu_backupActionPerformed(evt);
            }
        });
        jm_menu_opcoes.add(jm_menu_backup);

        jm_menu_restaurar_backup.setText("Restaurar backup");
        jm_menu_restaurar_backup.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jm_menu_restaurar_backupActionPerformed(evt);
            }
        });
        jm_menu_opcoes.add(jm_menu_restaurar_backup);

        jm_menu_usuarios.setText("Gerenciar usuários");
        jm_menu_opcoes.add(jm_menu_usuarios);

        jm_menu_sair.setText("Sair");
        jm_menu_sair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jm_menu_sairActionPerformed(evt);
            }
        });
        jm_menu_opcoes.add(jm_menu_sair);

        jm_menu.add(jm_menu_opcoes);

        jm_menu_gerenciar.setText("Gerenciar");

        jm_menu_clinicas.setText("Clinicas");
        jm_menu_clinicas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jm_menu_clinicasActionPerformed(evt);
            }
        });
        jm_menu_gerenciar.add(jm_menu_clinicas);

        jm_menu_dentistas.setText("Dentistas");
        jm_menu_dentistas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jm_menu_dentistasActionPerformed(evt);
            }
        });
        jm_menu_gerenciar.add(jm_menu_dentistas);

        jm_menu_pacientes.setText("Pacientes");
        jm_menu_pacientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jm_menu_pacientesActionPerformed(evt);
            }
        });
        jm_menu_gerenciar.add(jm_menu_pacientes);

        jm_menu_ordem_de_servico.setText("Ordem de Serviço");
        jm_menu_ordem_de_servico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jm_menu_ordem_de_servicoActionPerformed(evt);
            }
        });
        jm_menu_gerenciar.add(jm_menu_ordem_de_servico);

        jm_menu.add(jm_menu_gerenciar);

        jm_menu_ajuda.setText("Ajuda");

        jm_menu_conteudo_ajuda.setText("Conteúdo da ajuda");
        jm_menu_ajuda.add(jm_menu_conteudo_ajuda);

        jm_menu_sobre.setText("Sobre");
        jm_menu_ajuda.add(jm_menu_sobre);

        jm_menu.add(jm_menu_ajuda);

        setJMenuBar(jm_menu);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lbl_imagem, javax.swing.GroupLayout.DEFAULT_SIZE, 1868, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(62, 62, 62)
                .addComponent(lbl_imagem, javax.swing.GroupLayout.PREFERRED_SIZE, 532, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(156, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jm_menu_backupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jm_menu_backupActionPerformed
        Base base = new Base();
        int resp = JOptionPane.showConfirmDialog(null, "Realizar Backup?", "Backup", JOptionPane.YES_NO_OPTION);
        if (resp == JOptionPane.YES_OPTION) {
            base.backup();
        }
    }//GEN-LAST:event_jm_menu_backupActionPerformed

    private void jm_menu_restaurar_backupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jm_menu_restaurar_backupActionPerformed
        Base base = new Base();
        int resp = JOptionPane.showConfirmDialog(null, "Realizar Backup?", "Backup", JOptionPane.YES_NO_OPTION);
        if (resp == JOptionPane.YES_OPTION) {
            base.restaurarBackup();
        }
    }//GEN-LAST:event_jm_menu_restaurar_backupActionPerformed

    private void jm_menu_sairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jm_menu_sairActionPerformed
        dispose();
    }//GEN-LAST:event_jm_menu_sairActionPerformed

    private void jm_menu_clinicasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jm_menu_clinicasActionPerformed
        frm_clinicas clinicas = new frm_clinicas(nivel_acesso);
        clinicas.setVisible(true);
       // this.setVisible(false);
    }//GEN-LAST:event_jm_menu_clinicasActionPerformed

    private void jm_menu_dentistasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jm_menu_dentistasActionPerformed
        frm_dentistas dentistas = new frm_dentistas(nivel_acesso);
        dentistas.setVisible(true);
      //  this.setVisible(false);
    }//GEN-LAST:event_jm_menu_dentistasActionPerformed

    private void jm_menu_pacientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jm_menu_pacientesActionPerformed
        frm_pacientes pacientes = new frm_pacientes(nivel_acesso);
        pacientes.setVisible(true);
       // this.setVisible(false);
    }//GEN-LAST:event_jm_menu_pacientesActionPerformed

    private void jm_menu_ordem_de_servicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jm_menu_ordem_de_servicoActionPerformed
        frm_ordem_de_servico os = new frm_ordem_de_servico(nivel_acesso);
        os.setVisible(true);
       // this.setVisible(false);
    }//GEN-LAST:event_jm_menu_ordem_de_servicoActionPerformed

    private void jm_menu_opcoesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jm_menu_opcoesActionPerformed

        
    }//GEN-LAST:event_jm_menu_opcoesActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(frm_main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(frm_main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(frm_main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(frm_main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new frm_main(nivel_acesso).setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuBar jm_menu;
    private javax.swing.JMenu jm_menu_ajuda;
    private javax.swing.JMenuItem jm_menu_backup;
    private javax.swing.JMenuItem jm_menu_clinicas;
    private javax.swing.JMenuItem jm_menu_conteudo_ajuda;
    private javax.swing.JMenuItem jm_menu_dentistas;
    private javax.swing.JMenu jm_menu_gerenciar;
    private javax.swing.JMenu jm_menu_opcoes;
    private javax.swing.JMenuItem jm_menu_ordem_de_servico;
    private javax.swing.JMenuItem jm_menu_pacientes;
    private javax.swing.JMenuItem jm_menu_restaurar_backup;
    private javax.swing.JMenuItem jm_menu_sair;
    private javax.swing.JMenuItem jm_menu_sobre;
    public static javax.swing.JMenuItem jm_menu_usuarios;
    private javax.swing.JLabel lbl_imagem;
    // End of variables declaration//GEN-END:variables
}
